package demo.blue.controller;

import demo.blue.service.TestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jin Zheng
 * @since 1.0 2021-07-14
 */
@RestController
@RequestMapping("/test")
public class TestController {
	private static Logger logger = LoggerFactory.getLogger(TestController.class);

	private TestService testService;

	public TestController() {
	}

	@GetMapping("/test/{name}")
	public String test(@PathVariable("name") String name) {
		String str = "Hello, " + name;
		logger.info(str);
		return str;
	}

	@GetMapping("/request/{name}")
	public String request(@PathVariable("name") String name) {
		return testService.getSource(name);
	}

	@Autowired
	public void setTestService(TestService testService) {
		this.testService = testService;
	}
}
